package br.com.montezuma.empresarial.backend.core;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

/**
 * <pre>
 * @author : David Montezuma          
 * Purpose      :   Class Entity Manger Definition responsible by generation database and tables.
 * Amendment History                                                                
 * Date - Name - Description                              
 * 20/05/2012 - David Montezuma - initial version.
 * 
 * Copyright 2012 Montezuma Software
 * </pre>
 */
public class SessionFactorySingleton {
	private SessionFactory sessionFactory;
	private static SessionFactorySingleton d = null;

	private SessionFactorySingleton() {
	}

	public static SessionFactorySingleton getInstance() {
		if (d == null) {
			AnnotationConfiguration configuration = new AnnotationConfiguration();
			configuration.configure();
			d = new SessionFactorySingleton();
			d.setSessionFactory(configuration.buildSessionFactory());
		}
		return d;
	}

	public SessionFactory getSessionFactory() {
		return sessionFactory;
	}

	public void setSessionFactory(SessionFactory sessionFactory) {
		this.sessionFactory = sessionFactory;
	}

	

}